home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
datatypes
/
playdt13.lha
/
PlayDT
/
PlayDT-src
/
UseWB.c
< prev
Wrap
C/C++ Source or Header
|
1997-06-05
|
4KB
|
189 lines
/****************************************************************
*
* $VER: UseWB.c 1.3 (4.6.97) Tak Tang (tst92@ecs.soton.ac.uk)
*
* Copyright © 1997 Tak Tang
*
* You may use any part of this source code in your own programs
* provided that it is not called PlayDT.
*
******************************************************************
*
*/
/**** Header files ****/
#include "PlayDT.h"
#include <workbench/startup.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/datatypes_protos.h>
#include <clib/intuition_protos.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/datatypes_pragmas.h>
#include <pragmas/intuition_pragmas.h>
/****** UseWB ******************************************************
*
* NAME
* UseWB - call PlayFile for each arg passed by wb, or call asl
*
* SYNOPSIS
* UseWB ( GlobalData , WBArgArray )
*
* UseWB ( struct GlobalData * , struct WBStartup * );
*
* FUNCTION
* UseWB will attempt to call PlayFile() for each file passed by
* the workbench. If no files are passed, then UseWB will call
* UseAsl.
*
* INPUTS
* GlobalData -
*
* WBArgArray - a WBArg array passed by workbench
*
* RESULT
*
* EXAMPLE
*
* NOTES
*
* BUGS
*
* SEE ALSO
* UseCli.c/UseCli(), UseAsl.c/UseAsl()
*
*****************************************************************************
*
*/
void UseWB(struct GlobalData *gd, struct WBStartup *wbs)
{
struct WBArg *wba;
ULONG i;
BPTR oldlock;
gd->FromWB=TRUE;
if ( wbs->sm_NumArgs>1 )
{
wba=( wbs->sm_ArgList)+1;
for ( i= wbs->sm_NumArgs-1; i && FALSE==gd->UserStop; i--, wba++)
{
if (NULL!=wba->wa_Lock)
{
oldlock=CurrentDir( wba->wa_Lock );
if ( PlayFile(gd, wba->wa_Name) )
{
IntuiError( gd, wba->wa_Name );
} /* if error */
CurrentDir(oldlock);
} /* NULL != if wba_wa_Lock */
} /* for */
} /* if NumArgs>1 */
else
{
UseASL(gd);
} /* if NumArgs<2 */
} /* UseWB */
/****** IntuiError *************************************************
*
* NAME
* IntuiError - display the ioerr message using easyrequest
*
* SYNOPSIS
* IntuiError( GlobalData, FileName )
*
* IntuiError( struct tGlobalData *, STRPTR );
*
* FUNCTION
* This routine gets the ioerr using Fault(), and displays
* the message in a window using EasyRequest. The requester
* offers the user two options- OK and ABORT. Selecting ABORT
* will set the gd->UserStop flag.
* It will open intuition if it is not already open, but does
* not close it.
*
* INPUTS
* GlobalData - A pointer to structure containing library bases
* and other global data.
*
* FileName - The filename of the sound sample to play, relative
* to the current directory. This is not checked
* to see if it is a valid filename.
*
* RESULT
* (gd->UserStop) - This flag is set if we could not open
* intuition.library, or if the user selected
* ABORT
*
* EXAMPLE
*
* NOTES
*
* BUGS
*
* SEE ALSO
*
*****************************************************************************
*
*/
void IntuiError(struct GlobalData *gd, STRPTR filename)
{
LONG rc;
UBYTE buffer[81];
struct EasyStruct ez = {
sizeof(struct EasyStruct), 0, "PlayDT 1.3",
"%s: %s","OK|ABORT"};
/* open Intuition library if necessary */
if ( NULL == gd->IntuitionBase ) {
if (gd->IntuitionBase = OpenLibrary ("intuition.library", 39L))
{
IntuitionBase=gd->IntuitionBase;
}
}
if ( gd->IntuitionBase ) {
/* Generate the message */
rc=IoErr();
if (rc >= DTERROR_UNKNOWN_DATATYPE)
{
if ( 0==EasyRequest(NULL, &ez, NULL, filename, GetDTString (rc)) )
{
gd->UserStop=TRUE;
} /* if 0==choice */
}
else
{
if ( Fault( IoErr(), NULL, buffer, 81) )
{
if ( 0==EasyRequest(NULL, &ez, NULL, filename, buffer) )
{
gd->UserStop=TRUE;
} /* if 0==choice */
} /* if fault() */
}
} /* if intuitionbase */
else
{
/* MUST abort now */
gd->UserStop=TRUE;
} /* If cant open intuition */
} /* IntuiError */
/**** End of file ****/